﻿@{
    ViewBag.Title = "系统数据配置项";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="row">
    <div class="col-md-12">
      <div class="box box-primary">
            <div class="box-header with-border">
                <h3 class="box-title">系统数据列表</h3>
                <div class="box-tools">
                    <div class="input-group" style="width: 250px;">
                        <input type="text" class="form-control input-sm" placeholder="请输入名称进行模糊查询...">
                        <div class="input-group-btn">
                            <a class="btn btn-sm btn-default"><i class="fa  fa-search"></i></a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="box-body no-padding">
                <div class="mailbox-controls">
                    <div class="btn-group" id="partial_button_toolbar">
                        @{ Html.RenderPartial("~/Areas/Common/Views/Shared/_PartialButton.cshtml"); }
                    </div>
                    <a data-toggle="tooltip" title="刷新" class="btn btn-default btn-sm"><i class="fa fa-refresh">刷新</i></a>
                </div>
                <div class="mailbox-jqgrid">
                    <table id="list"></table>
                    <div id="pager"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    var $grid, height;

    $(function () {
        height = UtilWindowHeightWidth().WinH - 319;
        initGird();
    });

    //初始化表格
    function initGird() {
        $grid = $("#list").jgridview(
        {
            multiselect: false,
            shrinkToFit: true,
            url: "/System/App/GetApp",
            colModel: [
                { name: "AppId", hidden: true },
                { label: "代码", name: "Code", width: 100, fixed: true },
                { label: "名称", name: "Name", width: 200 },
                { label: "简称", name: "ShortName", width: 100, fixed: true },
                { label: "域名/Ip", name: "Domain", width: 200, fixed: true },
                { label: "程序Dll文件", name: "DllPath", width: 200 },
                { label: "备注", name: "Remark", width: 100, fixed: true },
                { label: "排序", name: "OrderNo", width: 50, fixed: true }
            ],
            height: height
        });
    }

    //获取表格数据
    function getGridData() {
        UtilAjaxPost("/System/App/GetApp", {}, function (data) { GridReloadLoadOnceData($grid, data); });
    }

    //操作:新增
    function add() {
        ArtDialogOpen("/System/App/Edit", "新增应用系统配置", 580);
    }

    //操作:编辑
    function edit() {
        //查看是否选中
        GridIsSelect($grid, function () {
            var info = GridGetSingSelectData($grid);
            ArtDialogOpen("/System/App/Edit?id=" + info.AppId, "修改应用系统配置-" + info.Name, 580);
        });
    }

    //删除匹配项
    function del() {
        //查看是否选中
        GridIsSelect($grid, function () {
            ArtDialogConfirm(Language.common.deletemsg, function () {
                UtilAjaxPostWait(
                    "/System/App/DeleteApp",
                    { id: GridGetSingSelectData($grid).AppId },
                    perateStatus
            );
            });
        });
    }

    //请求完成
    function perateStatus(data) {
        DialogAjaxResult(data);
        if (data.ResultSign === 0) {
            getGridData();
        }
    }

</script>